package com.chuanyang.driverh.mainhome;


import android.content.Intent;
import android.os.Bundle;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseTitleActivity;
import com.chuanyang.driverh.mainhome.fragment.DriverJoinFragment;
import com.chuanyang.driverh.mainhome.fragment.DriverNotJoinFragment;
import com.chuanyang.driverh.mainhome.fragment.FleetJoinFragment;

public class FleetJoinActivity extends BaseTitleActivity {

    private String fleet = "";
    private String jiameng = "";

    private FleetJoinFragment mFragment;//车队加盟
    private DriverNotJoinFragment driverNotJoinFragment;
    private DriverJoinFragment driverJoinFragment;

    @Override
    protected int getContentResId() {
        return R.layout.base_single_fragment_activity;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initData() {
        setBackImg();
        getTitleTextView().setText("业务加盟");
        getRightTextView().setText("申请");

        if(getIntent().getStringExtra("fleet") != null){
            fleet = getIntent().getStringExtra("fleet");
            if(fleet.equals("1")){//车队，加载车队加盟的fragment
                if (mFragment == null) {
                    mFragment = new FleetJoinFragment();
                }
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.single_fragment_content, mFragment).commit();
            }else if(fleet.equals("2")){//司机
                if(getIntent().getStringExtra("jiameng") != null){
                    jiameng = getIntent().getStringExtra("jiameng");
                    if(jiameng.equals("102")){//司机未加盟
                        //加载司机未加盟的fragment
                        if (driverNotJoinFragment == null) {
                            driverNotJoinFragment = new DriverNotJoinFragment();
                        }
                        getSupportFragmentManager().beginTransaction()
                                .add(R.id.single_fragment_content, driverNotJoinFragment).commit();
                    }else if (jiameng.equals("100")){//司机已加盟
                        //加载司机已加盟的fragment
                        if (driverJoinFragment == null) {
                            driverJoinFragment = new DriverJoinFragment();
                        }
                        getSupportFragmentManager().beginTransaction()
                                .add(R.id.single_fragment_content, driverJoinFragment).commit();
                    }
                }

            }
        }
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void baseGoEnsure(){
        //申请DriverJoinApplyActivity
        if(fleet != null){
            Intent intent = new Intent(FleetJoinActivity.this,DriverJoinApplyActivity.class);
            intent.putExtra("fleet",fleet);
            startActivity(intent);
        }
    }
}
